//
//  AboutUsViewController.swift
//  SchoolDemo
//
//  Created by rimi on 16/9/28.
//  Copyright © 2016年 YQ. All rights reserved.
//

import UIKit

class AboutUsViewController: UIViewController {
    var label1: UILabel?
    var label2: UILabel?
    var label3: UILabel?
    var label4: UILabel?
    var label5: UILabel?
    var label6: UILabel?
    var label7: UILabel?

    override func viewDidLoad() {
        super.viewDidLoad()
    //上方导航栏和图片设置
        setUI()
    //当前版本
        facing()
    //联系我们
        weare()
    //官网
        website()
    //下方版权
        downwriter()
    //小字
        Ntext()
    }
    //上方导航栏和图片设置
    func setUI() {
        view.backgroundColor = UIColor().colorWithHex(0xf0f0f0)
        
   
        label1 = UILabel(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 64))
        label1?.backgroundColor = UIColor().colorWithHex(0x009ee7)
        label1?.text = "关于我们"
        label1?.textColor = UIColor.white
        label1?.textAlignment = NSTextAlignment.center
        label1?.font = UIFont.systemFont(ofSize: 20)
        view.addSubview(label1!)
        
        let btn = UIButton()
        btn.frame = CGRect(x: 0, y: 13, width: 44, height: 44)
        btn.setImage(UIImage(named:"返回按钮"), for: UIControlState.normal)
        btn.center.x = self.view.bounds.width / 7
        //        btn.center.y = self.view.bounds.height
        btn.addTarget(self, action: #selector(clickedBtn), for: UIControlEvents.touchUpInside)
        view.addSubview(btn)
        let vieww = UIImageView()
        vieww.frame = CGRect(x: UIScreen.main.bounds.width / 2 - 75 , y: 104, width: 150, height: 150)
        vieww.image = UIImage(named:"logo")
        view.addSubview(vieww)
        
  

    }
    //当前版本
    func facing() {
        
        let thread = UIView()
        thread.frame = CGRect(x: 0, y: 273, width: UIScreen.main.bounds.width, height: 1)
        thread.backgroundColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)
        view.addSubview(thread)
        
        label2 = UILabel(frame: CGRect(x: 0, y: 274, width: UIScreen.main.bounds.width, height: 64))
        label2?.text = "  当前版本"
        label2?.textColor = UIColor().colorWithHex(0x4c4c4c)
        label2?.font = UIFont.systemFont(ofSize: 16)
        label2?.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        view.addSubview(label2!)
        
        
        label3 = UILabel(frame: CGRect(x: 0, y: 274, width: UIScreen.main.bounds.width, height: 64))
        label3?.text = "V6.0  "
        label3?.font = UIFont.systemFont(ofSize: 16)
        label3?.textColor = UIColor().colorWithHex(0xb2b2b2)
        label3?.textAlignment = .right
        label3?.alpha = 1
        view.addSubview(label3!)
        
        let btn2 = UIButton()
        btn2.frame = CGRect(x: 0, y: 274, width: UIScreen.main.bounds.width, height: 64)
        btn2.addTarget(self, action: #selector(facingBtn), for: .touchUpInside)
        view.addSubview(btn2)
        
        
        let thread1 = UIView()
        thread1.frame = CGRect(x: 0, y: 337, width: UIScreen.main.bounds.width, height: 1)
        thread1.backgroundColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)
        
        view.addSubview(thread1)
    }
    //联系我们
    func weare() {
        let thread = UIView()
        thread.frame = CGRect(x: 0, y: 357, width: UIScreen.main.bounds.width, height: 1)
        thread.backgroundColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)
        view.addSubview(thread)
        
        label4 = UILabel(frame: CGRect(x: 0, y: 358, width: UIScreen.main.bounds.width, height: 64))
        label4?.text = "  联系我们"
        label4?.textColor = UIColor().colorWithHex(0x4c4c4c)
        label4?.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        view.addSubview(label4!)
        
        label5 = UILabel(frame: CGRect(x: 0, y: 358, width: UIScreen.main.bounds.width, height: 64))
        label5?.text = "4008229991"
        label5?.textAlignment = .right
        label5?.font = UIFont.systemFont(ofSize: 16)
        label5?.textColor = UIColor().colorWithHex(0xd60a82)
        label5?.alpha = 1
        view.addSubview(label5!)
        
        let btn3 = UIButton()
        btn3.frame = CGRect(x: 0, y: 358, width: UIScreen.main.bounds.width, height: 64)
        btn3.addTarget(self, action: #selector(callwe), for: .touchUpInside)
        view.addSubview(btn3)
        
    }
   //官网
    func website(){
        let thread = UIView()
        thread.frame = CGRect(x: 20, y: 422, width: UIScreen.main.bounds.width - 40, height: 1)
        thread.backgroundColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)
        view.addSubview(thread)
        
        label6 = UILabel(frame: CGRect(x: 0, y: 423, width: UIScreen.main.bounds.width, height: 64))
        label6?.text = "  官方网站"
        label6?.textColor = UIColor().colorWithHex(0x4c4c4c)
        label6?.font = UIFont.systemFont(ofSize: 16)
        label6?.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        view.addSubview(label6!)
        
        label7 = UILabel(frame: CGRect(x: 0, y: 423, width: UIScreen.main.bounds.width, height: 64))
        label7?.text = "http://news.baidu.com"
        label7?.textColor = UIColor().colorWithHex(0xd60a82)
        label7?.font = UIFont.systemFont(ofSize: 16)
        label7?.textAlignment = .right
        label7?.alpha = 1
        view.addSubview(label7!)
        
        let btn4 = UIButton()
        btn4.frame = CGRect(x: 0, y: 423, width: UIScreen.main.bounds.width, height: 64)
        btn4.addTarget(self, action: #selector(touchwebsite), for: .touchUpInside)
        view.addSubview(btn4)
        
        let thread2 = UIView()
        thread2.frame = CGRect(x: 0, y: 487, width: UIScreen.main.bounds.width, height: 1)
        thread2.backgroundColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)
        view.addSubview(thread2)
        
        
    }
    //官网按钮回调
    func touchwebsite(){
        let detail = DetailViewController()
        present(detail, animated: true, completion: nil)
     
    }
    
    //联系我们按钮回调
    func callwe() {
        print("联系")
        let webView:UIWebView = UIWebView()
        let Url = URLRequest(url: URL(string: "tel://4008229991")!)
        webView.loadRequest(Url)
        view.addSubview(webView)
    }

    //当前版本按钮回调
    func facingBtn() {
      print("飞吧皮卡丘")
    }
    
    //左上角箭头监听回调
    func clickedBtn() {
        dismiss(animated: true, completion: nil)
    }
    
    //下方落款
    func downwriter() {
        let label = UILabel()
        label.frame = CGRect(x: 40, y: 547, width: UIScreen.main.bounds.width - 80, height: 44)
        label.textColor = UIColor().colorWithHex(0xd60a82)
        label.font = UIFont.systemFont(ofSize: 18)
        label.text = "成都睿峰科技有限公司 版权所有"
        view.addSubview(label)
        
    }
    func Ntext () {
        let text = UILabel ()
        text.frame = CGRect(x: 35, y: 587, width: UIScreen.main.bounds.width - 70, height: 44)
        text.textColor = UIColor().colorWithHex(0x666666)
        text.text = "Copright@2016=2020 Longteng cloud education. ALL Rights Reserved"
        text.numberOfLines = 0
        view.addSubview(text)
    }
}
